package org.fastsyncer.parser.framework;

import java.util.List;
import java.util.Map;
import java.util.Queue;

import org.fastsyncer.common.entity.MappingTask;
import org.json.JSONObject;

public interface Parser {

    /**
     * 批量读取数据源数据
     * @param mappingTask 驱动配置
     * @param startPos 开始位置
     * @param endPos 结束位置
     * @return
     * @throws Exception
     */
    List<Map<String, Object>> batchQuery(MappingTask mappingTask, Integer startPos, Integer endPos) throws Exception;

    /**
     * 批量插入数据源到目标源
     * @param mappingTask 驱动配置
     * @param rows 数据源数据
     * @param pos 同步数据起始位置
     * @param reasonQuene 错误记录
     * @return
     * @throws Exception
     */
    Integer[] batchInsert(MappingTask mappingTask, List<Map<String, Object>> rows, Integer[] pos, Queue<JSONObject> reasonQuene) throws Exception;

    /**
     * 插入
     * @param mappingTask
     * @param row
     * @return
     * @throws Exception
     */
    boolean insert(MappingTask mappingTask, Map<String, Object> row) throws Exception;

    /**
     * 更新
     * @param mappingTask
     * @param row
     * @return
     * @throws Exception
     */
    boolean update(MappingTask mappingTask, Map<String, Object> row) throws Exception;

    /**
     * 删除
     * @param mappingTask
     * @param row
     * @return
     * @throws Exception
     */
    boolean delete(MappingTask mappingTask, Map<String, Object> row) throws Exception;

}
